import React from 'react';
import Switch from 'antd/switch';
import Slider from 'antd/slider';
import Radio from 'antd/radio';
const RadioGroup = Radio.Group;
import InputNumber from 'antd/input-number';
import Button from 'antd/button';
import Icon from 'antd/icon';
import Row from 'antd/row';
import Col from 'antd/col';
import Upload from 'antd/upload';
import Modal from 'antd/modal';
const { confirm } = Modal;
import Input from 'antd/input';
import { loadData, saveToFile } from '../utils/db';

export default class Hello extends React.Component {

  constructor(props) {
    super(props);
    this.on_click = this.on_click.bind(this);

    this.state = {
      status: ''
    };
  }

  on_click(e) {
    var self = this;
    loadData().then(function (e) {
      console.log('then...', e);
      return 'then 01 - xxx';
    }).catch(function (e) {
      console.log('error...', e);
    }).then(function () {
      console.log('last then...', arguments);
      self.setState({
        status: ''
      });
    })
    //
    self.setState({
      status: 'loading'
    });
  }

  render() {
    const {props} = this;
    const { status } = this.state;
    return (
      <div>
        <Button onClick={this.on_click} loading={status==='loading'}>Do async</Button>
      </div>
    );
  }
};
